﻿using LoveEat.API.Read.Applications.Commands.Aquaculture;
using LoveEat.Domain.Aquaculture;
using LoveEat.ErrorCode;
using LoveEat.Infrastructure.Interfaces;
using MediatR;

namespace LoveEat.API.Read.Applications.CommandHandlers.Aquaculture
{
    public class HealthQueryCommandHandler : IRequestHandler<HealthQueryCommand, APIResult<List<HealthModel>>>
    {
        private readonly IBaseRespository<HealthModel> healRep;

        public HealthQueryCommandHandler(IBaseRespository<HealthModel> healRep)
        {
            this.healRep = healRep;
        }

        public Task<APIResult<List<HealthModel>>> Handle(HealthQueryCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<HealthModel>> result=new APIResult<List<HealthModel>>();
            result.Code=APIResultCode.查询成功;
            result.Message=APIResultCode.查询成功.ToString();

            var res=healRep.GetAll().Where(x=>!x.IsDelete);
            result.Data=res.ToList();


            return Task.FromResult(result);

        }
    }
}
